﻿using System;
using System.Linq;
using System.Collections.Generic;
using Kunlun.Models;
namespace Kunlun.BusinessLogic
{
    public partial class KunlunTemplete
    {
        public static readonly KunLunEntities entities = new KunLunEntities();
        /// <summary>
        /// 更具tempid获取同类型模板列表
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static List<Templete> GetTemplete(int id)
        {
            Templete p = entities.Templete.FirstOrDefault(t=>t.Tid==id);
			if (p == null) {
				return new List<Templete>();
			}
            Product product = entities.Product.FirstOrDefault(c => c.pid == p.ProductID);
            List<string> productid = (from t in KunlunProduct.GetProductByCategoryID(product.Classid)
                                select t.pid).ToList();
            List<Templete> list = (from t in entities.Templete
                                   where productid.Contains(t.ProductID)
                                      select t).ToList();
            return list;

        }
    }
}
